
#pragma once

#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Real.h"
#include "DataStructure/Input/Solver/AnaysisTypes.h"

SG_DATASTRUCTURE_POST_NAMESPACE_OPEN


/** \enum AnalysisType
 * 有限元分析类型
 * https://nexus.hexagon.com/documentationcenter/zh-CH/bundle/MSC_Nastran_2024.1/page/Nastran_Combined_Book/dmap/datablocks/TOC.OFP.Tables.xhtml#id_d213908e417
 */
enum class AnalysisType : SG::DataStructure::Common::I64
{
    ANALYSISTYPE_Unknown                   = 0,    ///< 静力分析
    ANALYSISTYPE_Static                    = 1,    ///< 静力分析
    ANALYSISTYPE_Modes                     = 2,    ///< 模态分析
    ANALYSISTYPE_Frequency                 = 5,    ///< 频率响应
    ANALYSISTYPE_DirectTransient           = 6,    ///< 时域瞬态
    ANALYSISTYPE_Buckl                     = 8,    ///< 线性屈曲
    ANALYSISTYPE_ComplexEigenvalues        = 9,    ///< 复特征值
    ANALYSISTYPE_NonlinearStatics          = 10,   ///< 非线性静力学
    ANALYSISTYPE_GeometricNonlinearStatics = 11,   ///< 几何非线性静力学
    ANALYSISTYPE_Heat                      = 1010  ///< 热分析
};

struct ResultDomains
{
    SG::DataStructure::Common::Id  m_id      = 0;  /// Domain identifier
    SG::DataStructure::Common::Id  m_Subcase = 0;  /// Subcase number
    SG::DataStructure::Common::I64 m_Step    = 0;  /// Step number

    /**
     * 分析类型对应的Code参考：
     * https://nexus.hexagon.com/documentationcenter/zh-CH/bundle/MSC_Nastran_2024.1/page/Nastran_Combined_Book/dmap/datablocks/TOC.OFP.Tables.xhtml#id_d213908e417
     */
    AnalysisType   m_Analysis           = AnalysisType::ANALYSISTYPE_Unknown;
    SG::DataStructure::Common::Real       m_TimeFrequencyEigr  = 0.0;  /// Time, frequency or real part of eigen value
    SG::DataStructure::Common::Real       m_Eigi               = 0.0;  /// Imaginary part if eigen value (if applicable)
    SG::DataStructure::Common::I64        m_Mode               = 0;    /// Mode number
    SG::DataStructure::Common::I64        m_DesignCycle        = 0;    /// Design cycle
    SG::DataStructure::Common::I64        m_Random             = 0;    /// Random code
    SG::DataStructure::Common::I64        m_SuperelementNumber = 0;    /// Superelement number
    SG::DataStructure::Common::Id         m_AfpmId             = 0;    /// afpm id
    SG::DataStructure::Common::Id         m_TrmcId             = 0;    /// trmc id
    SG::DataStructure::Common::I64        m_Instance           = 0;    /// Instance
    SG::DataStructure::Common::I64        m_Module             = 0;    /// Module
    SG::DataStructure::Common::I64        m_Substep            = 0;    /// SUBSTEP Number
    SG::DataStructure::Common::Id         m_ImperfectionId     = 0;    /// Imperfection id

    bool operator< (ResultDomains& b)
    {
        return m_id < b.m_id;
    }
};

///< @brief 判断数据是否相等
DECLSPEC bool operator== (const ResultDomains& a, const ResultDomains& b);

///< @brief Convert SOLType to AnalysisType
DECLSPEC AnalysisType ConvertSOLTypeToAnalysisType(const SG::DataStructure::FEM::SOLType& solType);

SG_DATASTRUCTURE_POST_NAMESPACE_CLOSE